﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using Abp.AutoMapper;
using Abp.Domain.Entities;
using FwProject.Comm.ExcelUtil;
using FwProject.Restaurant.Dto;

namespace FwProject.PrePaymentInfo.Dto
{
    /// <summary>
    /// 收款模型
    /// </summary>
    [DisplayName(displayName: "收款单")]
    [AutoMap(typeof(ReceiptInfoModel))]
    public class ReceiptInfoDto:Entity<Guid>
    {
        public Guid? PaymentinfoId { get; set; }
        /// <summary>
        /// 所属工厂
        /// </summary>
        public Guid FactoryinfoId { get; set; }
        /// <summary>
        /// 收款单号
        /// </summary>
        [DisplayName(displayName: "收款单号")]
        [ExcelDateMember]
        public string ReceiptInfoNumber { get; set; }
        /// <summary>
        /// 经办人姓名
        /// </summary>
        [DisplayName(displayName: "经办人")]
        [ExcelDateMember]
        public string AgentPeoper { get; set; }
        /// <summary>
        /// 经办人id
        /// </summary>
        public long AgentPeoperUserId { get; set; }
        /// <summary>
        /// 收款时间
        /// </summary>
        [DisplayName(displayName: "收款时间")]
        [ExcelDateMember]
        public DateTime? Dateofreceipt { get; set; }
        /// <summary>
        /// 缴款经办人
        /// </summary>
        [DisplayName(displayName: "缴款经办人")]
        [ExcelDateMember]
        public string PaymentPerson { get; set; }
        /// <summary>
        /// 缴款经办人id
        /// </summary>
        public long? PaymentPersonUserId { get; set; }
        /// <summary>
        /// 缴款时间
        /// </summary>
        [DisplayName(displayName: "缴款时间")]
        [ExcelDateMember]
        public DateTime? DateofPayment { get; set; }

        public Guid RestaurantId { get; set; }

        [DisplayName(displayName: "餐厅")]
        [ExcelDateMember]
        public string RestaurantName { get; set; }

        public RestaurantDto RestaurantInfoModel { get; set; }

        /// <summary>
        /// 账户编号
        /// </summary>
        public Guid CapitalAccountId { get; set; }
        /// <summary>
        /// 账户名称
        /// </summary>
        [DisplayName(displayName: "账户名称")]
        [ExcelDateMember]
        public string AccountName { get; set; }

        /// <summary>
        /// 整单金额 此金额是后台制单后的应收金额SettlementInfo Actualprice 字段
        /// </summary>
        [DisplayName(displayName: "整单金额")]
        [ExcelDateMember(IsSum =true)]
        public decimal WholeAmount { get; set; }
        /// <summary>
        /// 应收回金额(WholeAmount-PreferentialAmount)
        /// </summary>
        [DisplayName(displayName: "应收回金额")]
        [ExcelDateMember(IsSum = true)]
        public decimal ActualAmount { get; set; }
        /// <summary>
        /// 使用预收款
        /// </summary>
        [DisplayName(displayName: "使用预收款")]
        [ExcelDateMember(IsSum = true)]
        public decimal UsePrePayment { get; set; }
        /// <summary>
        /// 实际收回金额
        /// </summary>
        [DisplayName(displayName: "实际收回金额")]
        [ExcelDateMember(IsSum = true)]
        public decimal TaskBackAmount { get; set; }
        /// <summary>
        /// 预收款剩余金额
        /// </summary>
        [DisplayName(displayName: "预收款剩余金额")]
        [ExcelDateMember(IsSum = true)]
        public decimal UsePrePaymentSurplus { get; set; }
        /// <summary>
        /// 优惠金额
        /// </summary>
        [DisplayName(displayName: "优惠金额")]
        [ExcelDateMember(IsSum = true)]
        public decimal PreferentialAmount { get; set; }

        /// <summary>
        /// 折扣率
        /// </summary>
        [DisplayName(displayName: "折扣率")]
        [ExcelDateMember]
        public string DiscountRate { get { return (Convert.ToDouble(PreferentialAmount) / Convert.ToDouble(WholeAmount)).ToString("0.00%"); } }

        /// <summary>
        /// 收款状态 0 未审核1已审核
        /// </summary>
        [DisplayName(displayName: "收款状态")]
        [ExcelDateMember]
        public ReceiptInfoStatus ReceiptInfoStatus { get; set; } = ReceiptInfoStatus.未提交;
        /// <summary>
        /// 审核时间
        /// </summary>
        [DisplayName(displayName: "审核时间")]
        [ExcelDateMember]
        public DateTime? AudtiTime { get; set; }
        /// <summary>
        /// 缴款状态 0 未缴款 1已缴款
        /// </summary>
        [DisplayName(displayName: "缴款状态")]
        [ExcelDateMember]
        public PaymentState PaymentState { get; set; } = PaymentState.未缴款;

        /// <summary>
        /// 交款时间
        /// </summary>
        [DisplayName(displayName: "交款时间")]
        [ExcelDateMember]
        public DateTime? PaymentTime { get; set; }

        /// <summary>
        /// 作废状态 0未作废1作废
        /// </summary>
        [DisplayName(displayName: "作废状态")]
        [ExcelDateMember]
        public ToVoidStatus ToVoid { get; set; } = ToVoidStatus.未作废;

        /// <summary>
        /// 备注
        /// </summary>
        [DisplayName(displayName: "备注")]
        [ExcelDateMember]
        public string RemarksConten { get; set; }
    }
}
